//
//  loadingIndicator.swift
//  Motion
//
//  Created by 悦月越悦 on 2021/3/21.
//

import SwiftUI
import UIKit

struct loadingIndicator: View {
    var body: some View {
        Spinner(style: .medium)
            .frame(idealWidth: .infinity, maxWidth: .infinity, alignment: .center)
    }
}

struct Spinner: UIViewRepresentable {
    let style: UIActivityIndicatorView.Style

    func makeUIView(context: Context) -> UIActivityIndicatorView {
        let spinner = UIActivityIndicatorView(style: style)
        spinner.hidesWhenStopped = true
        spinner.startAnimating()
        return spinner
    }
    
    func updateUIView(_ uiView: UIActivityIndicatorView, context: Context) {}
}

struct loadingIndicator_Previews: PreviewProvider {
    static var previews: some View {
        loadingIndicator()
    }
}

